package com.talkyun.utils.test.crypt;

import com.talkyun.utils.MD5;
import com.talkyun.utils.crypt.StreamCryptService;

import java.io.*;

public class AesCryptStreamMain {

    public static void main(String[] args) throws FileNotFoundException {

        StreamCryptService scs = new StreamCryptService();
        System.out.println(scs.getKeyPass("xxd2xxe3xxf", "AES"));

        String keyBody = "GW74ZKURRJ5HC337IX2ISSZTZWIYPRBV5GG2TJXNMYZVO3YZDYPQ";

        // InputStream ins = new FileInputStream("/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/60e3bd2e6665de68adc3306a.png");
        // OutputStream out = new FileOutputStream("/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/60e3bd2e6665de68adc3306a.png.dst");

        // String insFile = "/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/60e3bd2e6665de68adc3306a.png";
        String insFile = "/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/src.txt";
        InputStream ins = new FileInputStream(insFile);
        // String outFile = "/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/60e3bd2e6665de68adc3306a.png.dst";
        String outFile = "/Users/kevin/studio/openx-2.5.x/openx-utils/src/test/resources/dst.txt";

//        OutputStream out = new FileOutputStream(outFile);
//        scs.encrypt("AES", keyBody, ins, out);

        InputStream dins = new FileInputStream(outFile);
        OutputStream dout = new FileOutputStream(insFile + ".2");

        StreamCryptService scs2 = new StreamCryptService();
        scs2.decrypt("AES", keyBody, dins, dout);

        String md5In = MD5.md5File(insFile);
        System.out.println(md5In);
        String md5Out = MD5.md5File(insFile + ".2");
        System.out.println(md5Out);

        System.out.println(md5In.equals(md5Out));
    }
}
